/*
 * Copyright (c) 2020 hebeiyiliuba.com
 * All rights reserved.
 *
 */

package org.jeecg.modules.wlhy.taxstat;

import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.util.DictUtil;
import org.jeecg.modules.wlhy.customer.entity.HyCustomer;
import org.jeecg.modules.wlhy.taxstat.mapper.TaxStatMapper;
import org.jeecg.modules.wlhy.utils.UserUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @Description: TODO
 * @author: duanlikao
 * @date: 2022年10月24日 14:30
 */
@Api(tags="统计分析")
@RestController
@RequestMapping("/tj")
@Slf4j
public class TaxStatController {

    @Resource
    private TaxStatMapper taxStatMapper;


    @Resource
    private DictUtil dictUtil;

    @Resource
    private UserUtil userUtil;

    @GetMapping(value = "/taxstat")
    public Result<?> orderTj(@RequestParam(required = false) Map<String,String> params) {
        HyCustomer customer = userUtil.getCustomer();
        if(customer != null){
            params.put("customerId" , customer.getId());
        }
        if(StringUtils.isNotBlank(params.get("startMonth"))){
            params.put("startMonth" , params.get("startMonth").substring(0,7));
        }
        if(StringUtils.isNotBlank(params.get("endMonth"))){
            params.put("endMonth" , params.get("endMonth").substring(0,7));
        }

        List<?> list = dictUtil.parseArrayListDict( taxStatMapper.getTaxShippingMonthTotal(params) );
        return Result.OK(list);
    }

}
